import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  routes: [{
      path: '/index',
      name: 'index',
      component: () => import('@/views/index.vue'),
      beforeEnter: (to, from, next) => {
        if (sessionStorage.getItem('token')) {
          next();
        } else {
          alert('请先登录')
          next('/login')
        }
      }
    },
    {
      path: '/',
      redirect: 'index'
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login.vue')
    }
    // {
    //   path: '/about',
    //   name: 'about',
    //   component: () => import( './views/About.vue')
    // }
  ]
})